
package DataBase;


import edu.mit.jwi.IDictionary;
import edu.mit.jwi.item.*;
import java.util.*;
import java.util.ArrayList;


/**
 *
 * @author FY
 */
public class VerbSense extends Sense{
/*
 *     public ArrayList<Sense> getAntonyms()               //return a list of Antonyms
 *     public ArrayList<Sense> getAlsosees()               //return a list of Alsosees
 *     public ArrayList<Sense> getHypernyms()              //return a list of Hypernyms
 *     public ArrayList<Sense> getTroponyms()              //return a list of Troponyms
 *     public ArrayList<Sense> getCoordinateTerms()        //return a list of Coordinate Terms
 *     public ArrayList<Sense> getEntails()                //return a list of Entails
 *     public ArrayList<Sense> getDerivations()            //return a list of Devirations
 *     public ArrayList<Sense> getCauses()                 //return a list of Causes
 *     public ArrayList<String> getSentenceFrames()            //return a list of SentenceFrames
 *     public ArrayList<Sense> getTopics()                 //return a list of Topics
 *     public ArrayList<Sense> getRegions()                //return a list of Regions
 *     public ArrayList<Sense> getUsages()                 //return a list of Usages
 *     public ArrayList<Sense> getVerbGroups()             //return a list of VerbGroups
 *
 *
 *
 *     public boolean hasAntonyms()        //return a boolean var indicating whether the verb has such attribute
 *     public boolean hasAlsosees()       
 *     public boolean hasHypernyms()
 *     public boolean hasTroponyms()
 *     public boolean hasCoordinateTerms()
 *     public boolean hasEntails()
 *     public boolean hasDerivations()
 *     public boolean hasCauses()
 *     public boolean hasSentenceFrames()
 *     public boolean hasTopics()
 *     public boolean hasRegions()
 *     public boolean hasUsages()
 *     public boolean hasVerbGroups()
*/

    public VerbSense(String Lemma,IDictionary dict_,POS PP,int Sense_cnt){
        super(Lemma, dict_, PP, Sense_cnt);

    }

    public VerbSense(IDictionary dict, ISynset synset) {
        super(dict, synset);
    }
    public VerbSense(IDictionary dict, IWord w) {
        super(dict, w);
    }

    public VerbSense(Sense s)
    {
        super(s.dict,s.synset);
    }


    public boolean hasAntonyms()
    {
        List < IWordID > anton = iwd.getRelatedWords (Pointer.ANTONYM );
        if (anton.isEmpty())
            return false;
        return true;
    }

    public ArrayList<Sense> getAntonyms()               //return a list of Antonyms
    {
           ArrayList<Sense> ant = new ArrayList<Sense>();
           List < IWordID > anton = iwd.getRelatedWords (Pointer.ANTONYM );
	   for( IWordID wid : anton )
	   {
                IWord word = dict . getWord ( wid );
		ant.add(new VerbSense(dict,word));
	   }
	   return ant;
    }

    public boolean hasHypernyms()
    {
        List < ISynsetID > anton = synset.getRelatedSynsets (Pointer.HYPERNYM );
        if (anton.isEmpty())
            return false;
        return true;
    }


     public ArrayList<Sense> getHypernyms()               //return a list of Hypernyms
    {
           ArrayList<Sense> hyp = new ArrayList<Sense>();
           List < ISynsetID > hypern = synset.getRelatedSynsets (Pointer.HYPERNYM);
	   for( ISynsetID sid : hypern )
	   {
		   hyp.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
	   return hyp;
    }

    public boolean hasTroponyms()
    {
        List < ISynsetID > anton = synset.getRelatedSynsets (Pointer.HYPONYM );
        if (anton.isEmpty())
            return false;
        return true;
    }

     public ArrayList<Sense> getTroponyms()               //return a list of Troponyms
    {
           ArrayList<Sense> trp = new ArrayList<Sense>();
           List < ISynsetID > tropon = synset.getRelatedSynsets (Pointer.HYPONYM);
	   for( ISynsetID sid : tropon )
	   {
		   trp.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
	   return trp;
    }

    public boolean hasCoordinateTerms()
    {
        List < ISynsetID > anton = synset.getRelatedSynsets (Pointer.HYPERNYM );
        if (anton.isEmpty())
            return false;
        return true;
    }

    public ArrayList<Sense> getCoordinateTerms()        //return a list of Coordinate Terms
    {
           ArrayList<VerbSense> mid = new ArrayList<VerbSense>();
           ArrayList<Sense> ct = new ArrayList<Sense>();
           List < ISynsetID > hyp = synset.getRelatedSynsets (Pointer.HYPERNYM);
           for( ISynsetID sid: hyp)
           {
               mid.add(new VerbSense(dict, dict.getSynset(sid)));
           }
           for( VerbSense vs: mid)
           {
                 List < ISynsetID > tropon = vs.synset.getRelatedSynsets (Pointer.HYPONYM);
                 for( ISynsetID sid : tropon )
                 {
		     ct.add(new VerbSense(dict,dict.getSynset(sid)));
                 }
           }
           return ct;
    }


    public boolean hasDevirations()
    {
        List < IWordID > anton = iwd.getRelatedWords (Pointer.DERIVATIONALLY_RELATED );
        if (anton.isEmpty())
            return false;
        return true;
    }

     public ArrayList<Sense> getDerivations()            //return a list of Devirations
    {
           ArrayList<Sense> drf = new ArrayList<Sense>();
           List < IWordID > der = iwd.getRelatedWords (Pointer.DERIVATIONALLY_RELATED );
	   for( IWordID wid : der )
	   {
                IWord word = dict . getWord ( wid );
		drf.add(new VerbSense(dict,word));
	   }
	   return drf;
     }


     public boolean hasEntails()
    {
        List < ISynsetID > anton = synset.getRelatedSynsets (Pointer.ENTAILMENT);
        if (anton.isEmpty())
            return false;
        return true;
    }

     public ArrayList<Sense> getEntails()               //return a list of Entailiments
    {
           ArrayList<Sense> et = new ArrayList<Sense>();
           List < ISynsetID > en = synset.getRelatedSynsets (Pointer.ENTAILMENT);
	   for( ISynsetID sid : en )
	   {
		   et.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
	   return et;
    }

    public boolean hasCauses()
    {
        List < ISynsetID > anton = synset.getRelatedSynsets (Pointer.CAUSE);
        if (anton.isEmpty())
            return false;
        return true;
    }

    public ArrayList<Sense> getCauses()               //return a list of Causes
    {
           ArrayList<Sense> cs = new ArrayList<Sense>();
           List < ISynsetID > ca = synset.getRelatedSynsets (Pointer.CAUSE);
	   for( ISynsetID sid : ca )
	   {
		   cs.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
	   return cs;
    }

    public boolean hasVerbGroups()
    {
        List < IWordID > anton = iwd.getRelatedWords (Pointer.VERB_GROUP );
        List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.VERB_GROUP);
        if (anton.isEmpty() && ver.isEmpty())
            return false;
        return true;
    }

    public ArrayList<Sense> getVerbGroups_t()               //return a list of VerbGroups
            //a little problem with"kill"
    {
           ArrayList<Sense> vg = new ArrayList<Sense>();
           List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.VERB_GROUP);
	   for( ISynsetID sid : ver )
	   {
		   vg.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
           List < IWordID > der = iwd.getRelatedWords (Pointer.VERB_GROUP );
	   for( IWordID wid : der )
	   {
                IWord word = dict . getWord ( wid );
		vg.add(new VerbSense(dict,word));
	   }
	   return vg;
    }

    public ArrayList<Sense> getVerbGroups()               //return a list of VerbGroups
            //a little problem with"kill"
    {
           ArrayList<Sense> vg = getVerbGroups_t();
           ArrayList<Sense> tmp = new ArrayList<Sense>();
           for(Sense ss: vg)
           {
                VerbSense vs = new VerbSense(ss);
                for (Sense st: vs.getVerbGroups_t())
                {
                    if (!vg.contains(st));
                    {
                        tmp.add(st);
                    }
               }
           }
           for (Sense ss: tmp)
           {
               if (!ss.get_Glosses().equals(synset.getGloss()))
               {
                   vg.add(ss);
               }

               
        }
           
	   return vg;
    }

    public boolean hasAlsoSees()
    {
        List < IWordID > anton = iwd.getRelatedWords (Pointer.ALSO_SEE );
        List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.ALSO_SEE);
        if (anton.isEmpty() && ver.isEmpty())
            return false;
        return true;
    }

    public ArrayList<Sense> getAlsosees()               //return a list of Alsosees
    {
           ArrayList<Sense> vg = new ArrayList<Sense>();
           List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.ALSO_SEE);
	   for( ISynsetID sid : ver )
	   {
		   vg.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
           ArrayList<Sense> drf = new ArrayList<Sense>();
           List < IWordID > der = iwd.getRelatedWords (Pointer.ALSO_SEE);
	   for( IWordID wid : der )
	   {
                IWord word = dict . getWord ( wid );
		vg.add(new VerbSense(dict,word));
	   }
	   return vg;
    }

    public boolean hasTopics()
    {
        List < IWordID > anton = iwd.getRelatedWords (Pointer.TOPIC );
        List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.TOPIC);
        if (anton.isEmpty() && ver.isEmpty())
            return false;
        return true;
    }


    public ArrayList<Sense> getTopics()               //return a list of Topics
    {
           ArrayList<Sense> vg = new ArrayList<Sense>();
           List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.TOPIC);
	   for( ISynsetID sid : ver )
	   {
		   vg.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
           List < IWordID > der = iwd.getRelatedWords (Pointer.TOPIC);
	   for( IWordID wid : der )
	   {
                IWord word = dict . getWord ( wid );
		vg.add(new VerbSense(dict,word));
	   }
	   return vg;
    }


     public boolean hasRegions()
    {
        List < IWordID > anton = iwd.getRelatedWords (Pointer.REGION );
        List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.REGION);
        if (anton.isEmpty() && ver.isEmpty())
            return false;
        return true;
    }


    public ArrayList<Sense> getRegions()               //return a list of Regions
    {
           ArrayList<Sense> vg = new ArrayList<Sense>();
           List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.REGION);
	   for( ISynsetID sid : ver )
	   {
		   vg.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
           List < IWordID > der = iwd.getRelatedWords (Pointer.REGION);
	   for( IWordID wid : der )
	   {
                IWord word = dict . getWord ( wid );
		vg.add(new VerbSense(dict,word));
	   }
	   return vg;
    }

    public boolean hasUsages()
    {
        List < IWordID > anton = iwd.getRelatedWords (Pointer.USAGE );
        List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.USAGE);
        if (anton.isEmpty() && ver.isEmpty())
            return false;
        return true;
    }

    public ArrayList<Sense> getUsages()               //return a list of Usages
    {
           ArrayList<Sense> vg = new ArrayList<Sense>();
           List < ISynsetID > ver = synset.getRelatedSynsets (Pointer.USAGE);
	   for( ISynsetID sid : ver )
	   {
		   vg.add(new VerbSense(dict,dict.getSynset(sid)));
	   }
           List < IWordID > der = iwd.getRelatedWords (Pointer.USAGE);
	   for( IWordID wid : der )
	   {
                IWord word = dict . getWord ( wid );
		vg.add(new VerbSense(dict,word));
	   }
	   return vg;
    }

    public boolean hasSentenceFrames()
    {
        if (iwd.getVerbFrames().isEmpty())
            return false;
        return true;
    }

    public ArrayList<String> getSentenceFrames()               //return a list of SentenceFrames
    {
        ArrayList<String> as = new ArrayList<String>();
        for(IVerbFrame iv: iwd.getVerbFrames())
        {
            as.add(iv.getTemplate());
        }
        return as;
    }
}
